% 
% @(#)Node.m	1.3  3/16/88
%
import _HandlerObject from "Builtins"
import _NodeListObject, _NodeListElementObject from "Builtins"
import _InStreamObject, _OutStreamObject from "Builtins"
export _NodeObject to "Builtins"

const _NodeObject == immutable object _NodeObject
  export getSignature, create, getStdin, getStdout

  const NodeType == type i_NodeType
    operation getActiveNodes -> [ _NodeListObject ]
    operation getAllNodes    -> [ _NodeListObject ]
    operation getNodeInformation [ Node ] -> [ _NodeListElementObject ]
    operation getTimeOfDay -> [ Time ]
    operation delay [ Time ]
    operation waitUntil [ Time ]
    operation getLoadAverage -> [ Real ]
    operation setNodeEventHandler [ _HandlerObject ]
    operation removeNodeEventHandler [ _HandlerObject ]
    operation getStdin -> [_InStreamObject]
    operation getStdout -> [_OutStreamObject]
    function  getLNN -> [Integer]
    function  getName -> [String]
  end i_NodeType

  function getSignature -> [ result : Signature ]
    result <- NodeType
  end getSignature
  operation getStdin -> [ result : _InStreamObject ]
    primitive 2008 [result] <- []
  end getStdin
  operation getStdout -> [ result : _OutStreamObject ]
    primitive 2108 [result] <- []
  end getStdout
  operation create -> [ n : NodeType ]
    n <- object aNode
      export 
 	getActiveNodes, getAllNodes, getNodeInformation,
	getTimeOfDay, delay, waitUntil, getLoadAverage,
	setNodeEventHandler, removeNodeEventHandler,
	getStdin, getStdout, getLNN, getName
	
      operation getTimeOfDay -> [ t : Time ]
	primitive "Node_getTimeOfDay" [ t ] <- [ ]
      end getTimeOfDay
      operation delay [ t : Time ]
	primitive 008 [ ] <- [ t ]
      end delay
      operation waitUntil [ t : Time ]
	primitive 108 [ ] <- [ t ]
      end waitUntil
      operation getActiveNodes -> [ r : _NodeListObject ]
 	primitive 208 [ r ] <- [ ]
      end getActiveNodes
      operation getAllNodes -> [ r : _NodeListObject ]
 	primitive 308 [ r ] <- [ ]
      end getAllNodes
      operation getNodeInformation [ n : Node ] -> [ r : _NodeListELementObject ]
 	primitive 408 [ r ] <- [ n ]
      end getNodeInformation
      operation getLoadAverage -> [ r : Real ]
	primitive "Node_getLoadAverage" [ r ] <- [ ]
      end getLoadAverage
      operation setNodeEventHandler [ h : _HandlerObject ]
	primitive 508 [ ] <- [ h ]
      end setNodeEventHandler
      operation removeNodeEventHandler [ h : _HandlerObject ]
	primitive 608 [ ] <- [ h ]
      end removeNodeEventHandler
      operation getStdin -> [ result : _InStreamObject ]
	primitive 708 [result] <- []
      end getStdin
      operation getStdout -> [ result : _OutStreamObject ]
	primitive 808 [result] <- []
      end getStdout
      function getLNN -> [result : Integer]
	primitive "Node_getLNN" [result] <- []
      end getLNN
      function getName -> [result : String]
	primitive 908 [result] <- []
      end getName
    end aNode
  end create
end _NodeObject
